package com.contexticon.Listeners;

import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;

public class OurFocusListener implements FocusListener {

	 public void focusGained(FocusEvent e) {
	        displayMessage("Focus gained", e);
	    }

	    public void focusLost(FocusEvent e) {
	        displayMessage("Focus lost", e);
	    }

	    void displayMessage(String prefix, FocusEvent e) {
	        System.out.println(prefix
	                       + (e.isTemporary() ? " (temporary):" : ":")
	                       +  e.getComponent().getClass().getName()
	                       + "; Opposite component: " 
	                       + (e.getOppositeComponent() != null ?
	                          e.getOppositeComponent().getClass().getName() : "null")
	                       + '\n'); 
	    }
	
}
